const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const Uglifyjs = require('uglifyjs-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const webpack = require('webpack')
const base = require('./webpack.base')
const { merge } = require('webpack-merge')

module.exports = merge(base,{
  mode: 'production',
  optimization: {
    minimizer: [
      new CssMinimizerPlugin(),
      new Uglifyjs({
        cache: true,   // 是否缓存
        parallel: true,  // 是否并发打包
        sourceMap: true  // 是否开启sourceMap
      })
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      ENV: JSON.stringify('prod')
    }),
    new CleanWebpackPlugin(),
  ]
})